import axios from "axios"
const key = "b892d33b2708fe24bf6af37ae39e07a7"
/* 请求拦截 */
axios.interceptors.request.use((config) => {
  let url = config.url
//   console.log(url)
  if (url.startsWith("/map")) {
    if (url.includes("?")) {
      config.url = `${url}&key=${key}`
    } else {
      config.url = `${url}?key=${key}`
    }
  }
  return config
})

/* axios响应拦截 */
axios.interceptors.response.use((response) => {
  return response.data
})

/* 天气获取 */
export const getWeatherHttp = (cityCode) => {
  return axios({
    url: `/map/weather/weatherInfo?city=${cityCode}`,
  })
}
